package koala.kuangjiademo.util;


import android.support.v4.view.ViewPager;
import android.widget.RadioGroup;

public class RadioGroupCheckedByViewPager implements ViewPager.OnPageChangeListener {
    private RadioGroup radioGroup;

    public RadioGroupCheckedByViewPager(RadioGroup radioGroup) {
        this.radioGroup = radioGroup;
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        if (position != -1) radioGroup.check(radioGroup.getChildAt(position).getId());
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }
}
